package com.chb.demo.controller;

import com.chb.demo.entity.Admin;
import com.chb.demo.entity.Performance;
import com.chb.demo.service.AdminService;
import com.chb.demo.service.PerformanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class PerformanceController {
    @Autowired
    PerformanceService performanceService;

    @RequestMapping("/getperformances")
    @ResponseBody  // 把返回的结果json序列化
    public Object getAdmins(@RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize) {
        Page<Performance> page = performanceService.findAllPerformance(pageNo, pageSize);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "ok");
        map.put("count", page.getTotalElements());
        map.put("data", page.getContent());
        return map;//hello.html..
    }

}
